package com.vincent.redispractise.part01.cacheBreakdownAndPassThrough;

import com.vincent.redispractise.dbClass.entity.Shop;
import com.vincent.redispractise.dbClass.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Des 缓存穿透
 *      缓存击穿
 * @Date 2023年2月20日23:22:54
 * @Param  * @param null
 * @Return
 */
@Slf4j
@RestController
@RequestMapping(value = "/shop")
public class BreakdownAndPassThrough {

    @Autowired
    private ShopService shopService;

    /**
     * @Des 查询店铺(解决缓存穿透 / 解决缓存击穿)
     * 参见笔记：穿透和击穿组合使用
     * @Date 2023年2月20日23:22:54
     * @Param * @param null
     * @Return
     */
    @GetMapping("/searchById")
    public Shop searchById(@RequestParam Long id) {
        return shopService.searchById(id);
    }
}
